<% if @results.length > 0
  pages = (@results.length.to_f/@page_limit.to_f).ceil.to_i
  if @results.length > @page_limit
    results = @results[((@page_nr.to_i*@page_limit.to_i)-@page_limit.to_i)..((@page_nr.to_i*@page_limit.to_i)-1)]
    first = (@page_nr.to_i*@page_limit.to_i)-(@page_limit.to_i-1)
    last = ((@page_nr.to_i*@page_limit.to_i) < @results.length) ? (@page_nr.to_i*@page_limit.to_i) : @results.length
  else
    results = @results
    first = 1
    last = @results.length
  end %>
  <div class="resultStats">
    <%= "Results <em>#{first}</em> to <em>#{last}</em> out of <em>#{@results.length}</em> for <em>#{@query[:search][:basic].join(' ')}</em>" %>
  </div>
  <% results.each do |result| %>
    <div class="resultBorder">
      <div class="result">
        <div class="actionContainer">
          <%= link_to_remote('preview', :update => 'previewContainer', :url => {:controller => 'search', :action => 'preview_item', :id => result[:object].id}, :after => 'togglePreview()', :html => {:class => 'preview'}) %>
          <span id="bookmark<%= result[:object].id %>"><%= render :partial => 'resource/items/bookmark', :locals => {:item_id => result[:object].id, :active => result[:object].bookmarked, :preview => 0} %></span>
        </div>
        <h3><%= (result[:object].source.nil?) ? result[:object].title : link_to(result[:object].title, result[:object].source_uri, :target => '_blank') %></h3>
        <p><%= result[:object].summary %></p>
        <div class="resultFooter">
          <%= link_to('referred', 'javascript: void(0);') %>
          <%= link_to('related', 'javascript: void(0);') %>
          <span>type: paper</span>
        </div>
      </div>
    </div>
  <% end 
  if @results.length > @page_limit %>
    <div class="paging">
      page:
      <% for p in 1..pages %>
        <%= link_to("#{p}", {:controller => 'search', :action => 'search', :q => @query[:naked][:query], :o => :@query[:naked][:options], :p => p}, :class => ((@page_nr.to_i == p.to_i) ? 'active' : nil)) %>
      <% end %>
    </div>
  <% end
else %>
  <div class="noResults">
    No results were found... please search again
  </div>
<% end %>